package view;

import org.uqbar.arena.actions.MessageSend;
import org.uqbar.arena.widgets.Button;
import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.windows.SimpleWindow;
import org.uqbar.arena.windows.WindowOwner;

import ApplicationModels.GestionEmpleadosAppModel;
import ApplicationModels.GestionTiendaAppModel;
import ApplicationModels.PlanificacionAppModel;

@SuppressWarnings("serial")
public class GestionTiendaWindow extends SimpleWindow<GestionTiendaAppModel> {

	public GestionTiendaWindow(WindowOwner parent, GestionTiendaAppModel model) {
		super(parent, model);

	}

	@Override
	protected void addActions(Panel actionsPanel) {
		new Button(actionsPanel).setCaption("Empleados")
				.onClick(new MessageSend(this, "empleados")).setAsDefault()
				.disableOnError();

		new Button(actionsPanel) //
				.setCaption("Planificador").onClick(
						new MessageSend(this, "planificar"));
	}

	@Override
	protected void createFormPanel(Panel mainPanel) {
		this.setTitle("Sistema de Gestion dela Tienda");

	}

	// /////////////////////ACCIONES////////////////////

	public void planificar() {
		this.openWindow(new PlanificacionWindow(this,
				new PlanificacionAppModel(this.getModelObject().getTienda())));
	}

	public void empleados() {
		this.openWindow(new GestionEmpleadosWindow(this,
				new GestionEmpleadosAppModel(this.getModelObject().getTienda())));
	}

	protected void openWindow(SimpleWindow<?> window) {
		window.open();
	}
}
